<?php
include "../include/global.php";
include "../include/admin_check.php";
include "../../FCKeditor/fckeditor.php";
$xtpl = new XTemplate ("faqWrite.htm");
include "setting.php";
//
include "../include/function.php";
$xtpl->assign("left_panel", left_panel());
$xtpl->assign("header_panel", header_panel());
$xtpl->assign("footer_panel", footer_panel());
include "setting.php";

// ++ lang
if($lang=='v'){
	$xtpl->assign('type_vietnamese', 'onkeyup="initTyper(this)"');
}
$xtpl->assign("title", Faq);
$xtpl->assign("lbl_search", Search);
$xtpl->assign("lbl_no", No);
$xtpl->assign("lbl_country", Country);
$xtpl->assign("lbl_name", Name);
$xtpl->assign("lbl_content", Content);
$xtpl->assign("lbl_position", Position);
$xtpl->assign("lbl_active", Active);
$xtpl->assign("lbl_save", Save);
$xtpl->assign("lbl_save_add", SaveAdd);
$xtpl->assign("lbl_cancel", Cancel);
// -- lang

$ID=intval($_GET['ID']);
if($ID){
	$sql="select * from ".pre_table."faq where faq_id='$ID'";
	$row=recordset($sql);
	$country_id=$row['country_id'];
	$faq_name=$row['faq_name'];
	$faq_content=$row['faq_content'];	
	$faq_position=$row['faq_position'];	
	$faq_isactive=$row['faq_isactive'];	
	
	if($row[faq_isactive]==1) $ChkActive = "checked";			
	
	$xtpl->assign("faq_name", $faq_name);
	$xtpl->assign("faq_content", $faq_content);
	$xtpl->assign("faq_position", $faq_position);
	$xtpl->assign("faq_isactive", $faq_isactive);
	$xtpl->assign("ChkActive", $ChkActive);
	$xtpl->assign("id", $ID);
	
	$xtpl->assign("type", "EDIT");	
}else{
	// ++ set position
	$stsql = "SELECT faq_id from ".pre_table."faq WHERE lang='".$lang."'";
	$rssql = execSQL($stsql);
	$numrec=mysql_num_rows($rssql);
	$faq_position=$numrec+1;
	$xtpl->assign("faq_position", $faq_position);
	// -- set position
	
	$xtpl->assign("type", "ADD");	
	$xtpl->assign("ChkActive", "checked");
}

$xtpl->assign("cbo_country", cbo_country($country_id));


$sBasePath="../../FCKeditor/"; 
$oFCKeditor = new FCKeditor('faq_content') ;
$oFCKeditor->BasePath	= $sBasePath ;
$oFCKeditor->Value		= $faq_content ;
$oFCKeditor->Width	= "100%" ;
$oFCKeditor->Height	= "300" ;

//////////////////////////////////////
$xtpl->parse("MAIN");
eval("?".">".$xtpl->text("MAIN"));
?>